﻿using System;

namespace Sencha.Serialization.Bson
{
	[TypeSerializer(typeof(Serializers.BsonUndefinedSerializer))]
	public sealed class BsonUndefined : IEquatable<BsonUndefined>
    {
		public static readonly BsonUndefined Value = new BsonUndefined();

        public BsonUndefined()
        {

        }

		#region IEquatable<BsonUndefined> Members

		public override bool Equals(object obj)
		{
			return (obj is BsonUndefined);
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}

		public bool Equals(BsonUndefined other)
		{
			return true;
		}

		#endregion

		public static bool operator ==(BsonUndefined a, BsonUndefined b)
		{
			if (ReferenceEquals(a, null) && ReferenceEquals(b, null))
				return false;
			else if (ReferenceEquals(a, null) || ReferenceEquals(b, null))
				return false;
			else
				return a.Equals(b);

		}
		public static bool operator !=(BsonUndefined a, BsonUndefined b)
		{
			return !(a == b);
		}

		public override string ToString()
		{
			return "undefined";
		}
	}
}
